package edu.bcu.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import edu.bcu.entity.Admin;
import edu.bcu.service.IAdminService;

@RestController
public class AdminController {
	
	@Autowired
	private IAdminService adminService;
	
	
	@RequestMapping("/addAdmin")
	public String addAdmin() {
		
		 adminService.addAdmin(new Admin(null,"ccc", 36, "123"));
		 return "ok";
	}
	
	@RequestMapping("/deleteAdminById")
	public String deleteAdminById() {
		adminService.deleteAdminById("2");
		return "ok";
	}
	
	@RequestMapping("/updateAdmin")
	public String updateAdmin(Admin admin) {
		adminService.updateAdmin(new Admin(1,"aaa",29,"123"));
		return "ok";
	}
	
	@RequestMapping("/getAdminById")
	public Admin getAdminById() {
		Admin admin = adminService.getAdminById("1");
		
		return admin;
	}
	
	
	@RequestMapping("/admin/getAllAdmin")
	public List<Admin> getAllAdmin() {
		List<Admin> admins = adminService.getAllAdmins();
		
		return admins;
	}
	
	
	

}
